package com.zimin.cloud.file.config;

import com.mongodb.client.MongoClient;
import com.mongodb.client.gridfs.GridFSBucket;
import com.mongodb.client.gridfs.GridFSBuckets;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * GridFs配置类
 *
 * @author zimin
 * @since 2022/4/8 10:54 上午
 */
@Component
public class GridFsConfig {

    @Value("${spring.data.mongodb.database}")
    private String mongodb;

    @Bean
    public GridFSBucket gridFsBucket(MongoClient mongoClient) {
        return GridFSBuckets.create(mongoClient.getDatabase(mongodb));
    }


}
